package com.muse.appManage.controller;

import com.muse.appManage.service.ManageUserService;
import com.muse.entity.Result;
import com.muse.interceptor.CurrentContext;
import com.muse.model.LoginParam;
import com.muse.model.UpdatePwdParam;
import com.muse.model.UserInfoVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created with IntelliJ IDEA.
 * User: lee
 * Date: 2021/4/25
 * Time: 10:29 上午
 * Description:
 */
@RestController
@RequestMapping(value = "/manage/login")
@Slf4j
public class ManageLoginController {

    @Autowired
    private ManageUserService manageUserService;


    @PostMapping("")
    public Result<UserInfoVo> login(@RequestBody LoginParam param) {
        return manageUserService.login(param);
    }

    @PostMapping("/updatePwd")
    public Result updatePwd(@RequestBody UpdatePwdParam param) {
        return manageUserService.updatePwd(param);
    }

    @GetMapping("/out")
    public Result out() {
        log.info(" Manage login out,id ={}", CurrentContext.getUserId());
        return manageUserService.out(CurrentContext.get().getToken());
    }

}
